import request from '@/utils/request'
import { getToken } from '@/utils/storage'

export const getNav = () => {
  return request.get('/v1_0/user/channels')
}
export const getList = (obj) => {
  const token = getToken()
  return request.get('/v1_0/articles', {
    params: {
      channel_id: obj.channel_id,
      timestamp: obj.timestamp
    },
    headers: {
      // 注意 Bearer 和 后面的空格不能删除，为后台的token辨识
      Authorization: `Bearer ${token}`
    }
  })
}
// 获取文章详情
export const getArticleDetail = (id) => {
  return request.get(`/v1_0/articles/${id}`, {
    params: {
      id
    }
  })
}
// 关注用户
export const getLike = (value) => {
  return request.post('/v1_0/user/followings', {
    target: value
  })
}
// 取消用户
export const delLike = (id) => {
  return request.delete(`/v1_0/user/followings/${id}`)
}
